﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;

    public class EscortRewardConfig extends Object
    {
        private var _dic:Dictionary;
        private static var _instance:EscortRewardConfig;

        public function EscortRewardConfig()
        {
            this._dic = new Dictionary();
            this.init();
            return;
        }// end function

        private function init() : void
        {
            var _loc_2:Object = null;
            var _loc_3:TEscortReward = null;
            this._dic = new Dictionary();
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_escort_reward.json");
            for each (_loc_2 in _loc_1)
            {
                
                _loc_3 = new TEscortReward();
                ClassTypesUtil.copyValue(_loc_3, _loc_2);
                this._dic[_loc_3.level] = _loc_3;
            }
            return;
        }// end function

        public function getItemByLevel(param1:int) : TEscortReward
        {
            var _loc_2:* = Math.floor(param1 / 10);
            var _loc_3:* = param1 % 10;
            var _loc_4:* = _loc_3 >= 5 && _loc_3 <= 9 ? (5) : (0);
            var _loc_5:* = int(_loc_2 + _loc_4.toString());
            return this._dic[_loc_5];
        }// end function

        public function getRewardByLevel(param1:int, param2:int, param3:int) : Array
        {
            var _loc_7:Array = null;
            var _loc_8:ItemData = null;
            var _loc_4:Array = [];
            var _loc_5:* = this.getItemByLevel(param1);
            var _loc_6:* = _loc_5.item.split("#");
            var _loc_9:* = _loc_6.length;
            var _loc_10:int = 0;
            while (_loc_10 < _loc_9)
            {
                
                _loc_7 = String(_loc_6[_loc_10]).split(",");
                _loc_8 = new ItemData(int(_loc_7[0]));
                _loc_8.itemAmount = int(_loc_7[1]) * param2;
                _loc_4.push(_loc_8);
                _loc_10++;
            }
            _loc_8 = new ItemData(800011010);
            _loc_8.serverData.itemAmount = _loc_5.exp * param3 * 0.01;
            _loc_4.push(_loc_8);
            _loc_8 = new ItemData(800011011);
            _loc_8.serverData.itemAmount = _loc_5.vital * param3 * 0.01;
            _loc_4.push(_loc_8);
            return _loc_4;
        }// end function

        public static function get instance() : EscortRewardConfig
        {
            if (!_instance)
            {
                _instance = new EscortRewardConfig;
            }
            return _instance;
        }// end function

    }
}
